﻿@using SAB.Domain.Acquisition
@{
    ViewBag.Title = "Buscar Proveedor";
}


@section Scripts
{
    <script src="@Url.Content("~/Scripts/Supplier.js")"></script>
   


}
<div class="row">
    <div class="col-md-12">
        <ol class="breadcrumb">
            <li>@Html.ActionLink("Home", "Index", "Home")</li>
            <li>@Html.ActionLink("Proveedor", "SearchSupplierResult", "Supplier")</li>
            <li class="active">Buscar </li>
        </ol>
    </div>
</div>

<div class="col-md-10">
    <div class="pull-right">
        <a href="@Url.Content("~/Supplier/SupplierRegister")" class="btn btn-primary">
            <i class="glyphicon glyphicon-plus"></i> Nuevo Proveedor
        </a>
    </div>
</div>
<br>
@{List<Supplier> proveedores = ViewData["allSupplier"] as List<Supplier>; }
<div class="row">
    <div class="col-md-12 title">
        <h1>Búsqueda Proveedor</h1>

    </div>
</div>
<div class="col-md-10">
    @if (TempData["message"] != null)
    {
        <div class="alert alert-success" role="alert">@TempData["message"]</div>
    }

</div>

<div class="col-md-10">

    <form action="@Url.Action("SearchSupplierResult", "Supplier")" class="form-horizontal" method="post" role="form">
        <div class=" form-group">
            <div class="row">
                <div class="col-md-6">
                    <label for="exampleInputEmail1">Código</label>
                    <input type="number" class="form-control" value= "@ViewData["searchCode"]" name="searchCode" id="exampleInputEmail1" min="1">
                </div>
                <div class="col-md-6">
                    <label for="exampleInputEmail1">RUC</label>
                    <input type="text" class="form-control" value="@ViewData["searchRUC"]" name="searchRUC" id="exampleInputEmail1" pattern="[0-9]*" title="Please enter numbers" maxlength="11">
                </div>

            </div>
        </div>


        <div class="form-group">
            <div class="row">
                <div class="col-md-6">
                    <label for="exampleInputEmail1">Nombre</label>
                    <input type="text" class="form-control" value="@ViewData["searchName"]" name="searchName" id="exampleInputEmail1" pattern="[a-zA-Z]*" title="Please enter letters" maxlength="25">
                </div>

                <div class="col-md-6">
                    <label for="exampleInputEmail1">Contacto</label>
                    <input type="text" class="form-control" value="" @ViewData["searchContacto"]  name="searchContacto" id="exampleInputEmail1" pattern="[a-zA-Z ]*" title="Please enter letters" maxlength="25">
                </div>
            </div>
        </div>

        <div class="form-group">
            <div class="row">
                <div class="col-md-6">
                    <label for="searchText">Fecha de Registro desde:</label>
                    <input type="text"  value="@ViewData["from"]" name="from" class="form-control generic-datepicker">
                </div>
                <div class="col-md-6">
                    <label for="searchText">Fecha de Registro hasta:</label>
                    <input type="text" value="@ViewData["to"]" name="to" class="form-control generic-datepicker">
                </div>
            </div>
        </div>






        <div class="col-sm-12" style="height:30px;"></div>
        <div class="form-group">
            <div class="col-sm-12">
                <input type="submit" class="btn btn-primary pull-right" value="Buscar" />
            </div>
        </div>
    </form>
</div>



<form action="@Url.Action("SearchSupplierResultDetail", "Supplier")" class="form-horizontal" method="post" role="form">
    <div class="col-md-10">
        <div class="row">
         
            <table class="table-responsive table table-striped">
                <tr>
                    <th class="cod">Código</th>
                    <th class="fechaDeRegistro">Fecha de Registro</th>
                    <th class="nombres">Nombre</th>
                    <th class="nombres">Contacto</th>
                    <th class="text-center"> </th>
                </tr>
                @{
                    if (proveedores != null) { 
                        foreach (Supplier r in proveedores) { 
                        <tr>
                            <td>@r.Id</td>
                            <td>@r.RegisterDate.ToShortDateString() </td>
                            <td>@r.Name</td>
                            <td>@r.Contacto</td>
                    
                            <td>
                                <a href="@Url.Action("SearchSupplierResultDetail", "Supplier", new { id = @r.Id })"><i class="margin-right-icon glyphicon glyphicon-zoom-in"></i></a>
                                <a href="@Url.Action("ModifySupplier", "Supplier", new { id = @r.Id })"><i class="margin-right-icon glyphicon glyphicon-pencil"></i></a>
                                <a class="DeleteSupplier" data-id="@r.Id"><i class="margin-right-icon glyphicon glyphicon-remove" data-toggle="modal" data-target="#deleteModal"></i></a>

                            </td>
                        </tr>
                      }
                     }
                }
                
               

            </table>

            


        </div>
    </div>





</form>


<!-- Modal -->
<div class="modal fade" id="deleteModal" tabindex="-1" role="dialog" aria-labelledby="myModalLabel" aria-hidden="true" style="display: none;">
    <div class="modal-dialog">
        <div class="modal-content">
            <div class="modal-header">
                <button type="button" class="close" data-dismiss="modal" aria-hidden="true">×</button>
                <h4 class="modal-title" id="myModalLabel">Confirmación</h4>
            </div>
            <div class="modal-body">
                <div>
                    <label class="control-label">
                        <!--for="inputFechaInicio" class="control-label"-->
                        ¿Estas seguro que quieres Eliminar
                    </label>
                    <label class="control-label">
                        este Proveedor?
                    </label>
                </div>
            </div>
            <div class="modal-footer">
                <button type="button" class="btn btn-default" data-dismiss="modal">Cerrar</button>
                <button id="btnAcceptDeleteSupplier" data-dismiss="modal" class="btn btn-primary">Aceptar</button>
            </div>

        </div>
    </div>
</div>

